package com.yihusitian.zsxq.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yihusitian.zsxq.pojo.dto.Group;
import org.springframework.stereotype.Service;
import com.yihusitian.zsxq.service.GroupService;
import com.yihusitian.zsxq.mapper.GroupMapper;
import com.yihusitian.zsxq.pojo.data.GroupDO;

/**
 * @Description TODO
 * @Author LeeHo
 * @Date 2021-03-25 11:49:28
 */
@Service
public class GroupServiceImpl extends ServiceImpl<GroupMapper, GroupDO> implements GroupService {

    @Override
    public GroupDO createGroup(Group group) {
        if (group == null) {
            return null;
        }
        GroupDO oldGroupDO = getById(group.getGroup_id());
        if (oldGroupDO != null) {
            return oldGroupDO;
        }
        GroupDO groupDO = GroupDO.builder().id(group.getGroup_id()).name(group.getName()).type(group.getType()).build();
        groupDO.insert();
        return groupDO;
    }
}